# Note: Makefile only compatible with gnu-make
# To compile:
# make          // will compile optimised version
# make dbg=y    // will compile debug version

# Basic flags
CC := g++
CFLAGS := -Wall -Wno-deprecated -std=c++0x
LDFLAGS := libtri.a

OPTFLAGS := -O2
DBGFLAGS := -g -DDEBUG
RM := rm -rf

# Executable
EXE := ass3

# Files
SOURCES := main.cpp graph_strat.cpp utils.cpp fact.cpp
HEADERS := tri.h fact.h graph_strat.h utils.h
OBJECTS := $(SOURCES:%.cpp=%.o)

OTHERFILES := libtri.a Makefile readme performance_ass3.ods readme.html
TESTFILES := test.sh testscript_testdata.csv
TURNINFILES := $(SOURCES) $(HEADERS) $(OTHERFILES) $(TESTFILES)



# Dependencies
DEPEND := $(OBJECTS:%.o=%.d)
-include $(DEPEND)

# For compiling different versions
dbg := n

ifeq ($(dbg), y)
	CFLAGS += $(DBGFLAGS)
else
	CFLAGS += $(OPTFLAGS)
endif

# Actual compile command
all : $(OBJECTS)
	$(CC) -o $(EXE) $(CFLAGS) $(OBJECTS) $(LDFLAGS)

# Rule for compiling object files
.cpp.o:
	$(CC) $(CFLAGS) -c $< -o $@


	



# Removing object files
.PHONY : clean
clean :
	$(RM) $(OBJECTS)

#turnin
.PHONY : turnin
turnin:
	turnin -c pucpp -p $(EXE) $(TURNINFILES)
	
.PHONY : zip
zip:
	zip  $(EXE).zip $(TURNINFILES)

